#!/bin/sh
#file-name=nbd_perf_dd.sh

cd /home/cuizheng
#LOG=/home/cuizheng/log/nbd_perf_dd_`date +"%Y-%m-%d=%H:%M:%S"`.log
LOG=/home/cuizheng/log/dd.log

echo "***********DD-Performance***********" >> $LOG

if [ -e $log ];then
	rm -f $LOG
fi
touch $LOG
_START=`date +"%s"`

i=1

while [ $i -le 3 ];
do
SUB=`uuidgen`

cd /home/cuizheng/file1
mkdir dd_tmp_$SUB
cd dd_tmp_$SUB

#echo "dd 5mb start" >> $LOG
#UUID=`uuidgen`
#START=`date +"%s"`
#dd if=/dev/zero of=./nbd_perf_test_file_$UUID.dat bs=512k count=10
#sync
#END=`date +"%s"` 
#echo "
#dd if=/dev/zero of=./nbd_perf_test_file_$UUID.dat bs=512k count=10
#sync
#START:$START,END:$END,SPEND:$((END-START))
#
#" >> $LOG


echo "dd 50mb start" >> $LOG
UUID=`uuidgen`
START=`date +"%s"`
dd if=/dev/zero of=./nbd_perf_test_file_$UUID.dat bs=512k count=102
sync
END=`date +"%s"`
echo "
dd if=/dev/zero of=./nbd_perf_test_file_$UUID.dat bs=512k count=102
sync
START:$START,END:$END,SPEND:$((END-START))

" >> $LOG

#echo "dd 500mb start" >> $LOG
#UUID=`uuidgen`
#START=`date +"%s"`
#dd if=/dev/zero of=./nbd_perf_test_file_$UUID.dat bs=512k count=1024
#sync
#END=`date +"%s"` 
#echo "
#dd if=/dev/zero of=./nbd_perf_test_file_$UUID.dat bs=512k count=102
#sync
#START:$START,END:$END,SPEND:$((END-START))
#
#" >> $LOG


echo "rm dd document start" >> $LOG
cd ..
START=`date +"%s"`
rm -rf dd_tmp_$SUB 
sync
END=`date +"%s"` 
echo "
rm -rf dd_tmp_$SUB
sync
START:$START,END:$END,SPEND:$((END-START))

" >> $LOG

i=$(($i + 1))
done

_END=`date +"%s"`

echo DD-Performance Total  START:$_START,END:$_END,SPEND:$((_END-_START)) >> $LOG

exit 1

#...10..........
#nohup sh nbd_perf_dd.sh 1>/home/cuizheng/nbd_perf_dd.log 2>&1 

